package com.example.java.thread;

public abstract class SheetTask {
    protected final int index;
    protected final Sheets sheets;

    public SheetTask(Sheets sheets, int index) {
        this.sheets = sheets;
        this.index = index;
    }

    protected final void ops() {
        while (sheets.getSheet(index) < 10000) {
            sheets.sheetAdd(index);
            System.out.println(Thread.currentThread().getId() + ":" + sheets.getSheet(index));
        }
    }

    protected final synchronized void sheet0Ops(){
        while (sheets.getSheet(0) < 10000){
            sheets.sheetAdd(0);
            System.out.println(Thread.currentThread().getId() + ":" + sheets.getSheet(0));
        }
    }
}
